const http = require('http')
const fs = require('fs')

http.createServer((req,res)=>{
    if(req.url=="/"){
        var fileContent = fs.readFileSync(__dirname+'/get.html')
        res.writeHead(200,{"Content-Type":"text/html;charset=utf8"})
        res.write(fileContent)
        res.end()
    }else{
        var urlObj = new URL(req.url,"http://localhost:8080/getdata")
        var newsId = urlObj.searchParams.get('newsId')
        console.log(newsId)
    }
}).listen(8080)